//
// Created by 原帅 on 2022/10/6.
//

#include "RTCPConnetor.h"

RTCPConnetor::RTCPConnetor(const char* ipAddr,short port) {
    this->type = SOCK_STREAM;
    for (int i = 0; i < IP_STR_MAX_SIZE; ++i) {
        if (ipAddr[i] != 0)
        {
            this->ipv4str[i] = ipAddr[i];
        }
    }
    this->port = port;
    this->serveraddr.sin_family = AF_INET;
    this->serveraddr.sin_port = htons(port);
    this->serveraddr.sin_addr.s_addr =inet_addr(this->ipv4str);
    this->ipv4 = serveraddr.sin_addr.s_addr;
}

int RTCPConnetor::doConnect() {
    this->sockfd = socket(AF_INET,type,IPPROTO_TCP);
    return connect(this->sockfd,(struct sockaddr*)&this->serveraddr,sizeof(struct sockaddr));
}

